package com.zmn.oms.api.listener;

import com.alibaba.fastjson.JSON;
import com.zmn.manager.mq.annotation.AliyunMQHandler;
import com.zmn.manager.mq.annotation.AliyunMQListener;
import com.zmn.oms.manager.utils.OmsMqTagConsts;
import com.zmn.oms.third.pinduoduo.dto.PinDuoDuoShopExamineDTO;
import com.zmn.oms.third.pinduoduo.service.PinDuoDuoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 类描述：拼多多审核结果处理
 *
 * @author wangxiaokun
 * @since 2020/7/14 10:01
 */
@Slf4j
@AliyunMQListener(topic = "${spring.mq.topic.oms}")
@Component
public class PinDuoDuoExamineListener {

    @Autowired
    private PinDuoDuoService pinDuoDuoService;

    @AliyunMQHandler(tags = OmsMqTagConsts.PDD_SHOP_EXAMINE_RESULT)
    public void examineResult(String message){
        try {
            log.info("#mq#examine# receive message:{}", message);
            PinDuoDuoShopExamineDTO dto = JSON.parseObject(message, PinDuoDuoShopExamineDTO.class);
            pinDuoDuoService.examineResult(dto);
        } catch (Exception e) {
            log.error("#mq#examine# {}", message, e);
        }
    }
}
